from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework import mixins, generics
from testapp.app_serializer import *
from testapp.models import *

# Create your views here.


class StudentsView(generics.ListCreateAPIView):
    queryset = Student.objects.all()
    serializer_class = StudentSerializer

    def post(self, request, *args, **kwargs):
        return self.create(request, *args, **kwargs)

    def get(self, request, *args, **kwargs):
        return self.list(request, *args, **kwargs)


class StudentsDetailView(generics.RetrieveUpdateAPIView):
    queryset = Student.objects.all()
    serializer_class = StudentSerializer


class TeachersView(generics.UpdateAPIView, generics.ListCreateAPIView, generics.DestroyAPIView):

    queryset = Teachers.objects.all()
    serializer_class = TeachersSerializer

    def post(self, request, *args, **kwargs):
        return self.create(request, *args, **kwargs)

    def get(self, request, *args, **kwargs):
        return self.list(request, *args, **kwargs)


class ClassesView(generics.UpdateAPIView, generics.ListCreateAPIView, generics.DestroyAPIView):
    queryset = Classes.objects.all()
    serializer_class = ClassSerializer

    def post(self, request, *args, **kwargs):
        return self.create(request, *args, **kwargs)

    def get(self, request, *args, **kwargs):
        return self.list(request, *args, **kwargs)
